<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8">
        <!-- 加入对静态文件路径的支持 -->
        {% load static %}

        <title>数据系统服务平台</title>
        <meta name="base_title" content="Charisma测试系统" />
        <!-- The styles -->
        <link id="bs-css" href="{% get_static_prefix %}charisma/css/bootstrap-cerulean.css" rel="stylesheet">
        <style type="text/css">  
          body {
                padding-bottom: 40px;
          }
          .sidebar-nav {
                padding: 9px 0;
          }
        </style>
        <link href="{% get_static_prefix %}charisma/css/bootstrap-responsive.css" rel="stylesheet">
        <link href="{% get_static_prefix %}charisma/css/charisma-app.css" rel="stylesheet">
        <link href="{% get_static_prefix %}charisma/css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
        <link href='{% get_static_prefix %}charisma/css/fullcalendar.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/fullcalendar.print.css' rel='stylesheet'  media='print'>
        <link href='{% get_static_prefix %}charisma/css/chosen.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/uniform.default.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/colorbox.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/jquery.cleditor.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/jquery.noty.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/noty_theme_default.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/elfinder.min.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/elfinder.theme.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/jquery.iphone.toggle.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/opa-icons.css' rel='stylesheet'>
        <link href='{% get_static_prefix %}charisma/css/uploadify.css' rel='stylesheet'>

        <!-- easy UI -->
        <link rel="stylesheet" type="text/css" href="{% get_static_prefix %}css/easyui/default/easyui.css"/> 
        <!-- 
        <link rel="stylesheet" type="text/css" href="{% get_static_prefix %}css/easyui/icon.css"/> 
        -->
        <!-- our own code -->
        <link href='{% get_static_prefix %}css/other.css' rel='stylesheet'>



        <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->


        <!-- The fav icon -->
        <link rel="shortcut icon" href="{% get_static_prefix %}charisma/img/favicon.ico">
</head>

<body>



<!-- content starts -->	
	<div>
		<ul class="breadcrumb">
			<li>
				databus <span class="divider">/</span>
			</li>
			<li>
				业务管理
			</li>
		</ul>
	</div>
	<div class="row-fluid sortable">
		<div class="box span12">
			<div class="box-header well" data-original-title>
				<h2><i class="icon-th"></i> 业务管理</h2>
			</div>
		<div>
			业务: <input type="text" class="input-xlarge required" id="add_business_name">
			<input type="button" class="btn btn-primary" onclick="add_business()" value="添加业务">
		</div>
			<div class="box-content" id="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
	<thead>
		<tr>
			<th>业务名称</th>
			<th>pos</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		{% for value in business_result_data %}
		<tr>
			<td><a href="{% url 'one_business' value %}"  >{{ value }}</a></td>
			<td><a href="{% url 'show_pos' value %}"  >{{ value }} pos点</a></td></td>
			<td><input type="button" class="btn btn-primary" onclick="delete_business('{{ value }}')" value="删除业务"></td>
		</tr>
		{% endfor %}
		<tr>
			<td colspan="6">一些说明信息</td>
		</tr>
	</tbody>
</table>
				
			</div>
		</div>
	</div>
	
	
<!-- content ends -->



 <!-- external javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->

        <!-- jQuery -->
        <script src="{% get_static_prefix %}charisma/js/jquery-1.7.2.min.js"></script>
 
<script language="JavaScript" type="text/javascript">
	//----------- start ---------------
	$(document).ready(function() {
		// 初始化 tooltip
		//$('.icon-question-sign').tooltip();
		// 触发一次搜索,很重要
		//$("#search_btn").click();
            });
	function add_business(){
		var business=$("#add_business_name").val();
		business=business.replace(/\s+/g,"");
		if(business==""){
			alert("业务名不能为空");
			return false;
		}
		$.ajax({
             type: "GET",
             url: "/business/add_bus_business/?business="+business,
             success: function(data){
                 if(data == "ok"){
             	 	alert("添加业务成功");
             	 }else if(data == "exist"){
             	 	alert("添加业务失败,业务已经存在");
                 }else if(data == "invalid") {
             	 	alert("添加业务失败,业务名无效,业务名应该包含_");
                 } else {
             	 	alert("添加业务失败,error:"+data);
             	 }
                 location.reload();
             },
             error:function(){
             	alert("add_business.... error, 请联系管理员");
             }
         });	
	}
	function delete_business(business){
		if(confirm("你确定要删除业务的所有数据源吗?!!!"))
		{
			$.ajax({
	             type: "GET",
	             url: "/business/delete_bus_business/?business="+business,
	             success: function(data){
	                 if(data=="ok"){
	             	 	alert("删除业务成功");
	             	 }else if(data == "run"){
	             	 	alert("删除业务失败, bus未停止");
                        } else {
                        	alert("删除业务失败,有错误发生，请检查日志");
                     }
	                 location.reload();
	             },
	             error:function(){
	             	alert("error,联系管理员");
	             }
	         });
         }	
	}
	
</script>

</body>
</html>
